bkLib.onDomLoaded( function() {
	new nicEditor({maxHeight:300,
		buttonList:['bold','italic','underline','strikeThrough','left','center','right','justify',
		            'ol','ul','fontSize','indent','outdent','forecolor']}).setPanel('post_panel').addInstance('post_text');
});

$(document).ready(function () {  
	var top = $('#float').offset().top - parseFloat($('#float').css('marginTop').replace(/auto/, 0));
	
	$(window).scroll(function (event) {
		var bottom = $(document).height() - 400;
		
		// what the y position of the scroll is
		var y = $(this).scrollTop();
		var y2 = $(this).scrollTop() + parseFloat($("#chat_box1").css('height')) +
			parseFloat($("#dict_box1").css('height')) + 20;
  
		// whether that's below the form
		if (y >= top) {
			if (y2 >= bottom) {
				$('#float').removeClass('fixed');
				$('#float').addClass('fixed_bottom');					
			} else {
				// if so, ad the fixed class
				$('#float').addClass('fixed');
				$('#float').removeClass('fixed_bottom');
			}
		} else {
			// otherwise remove it
			$('#float').removeClass('fixed');
			$('#float').removeClass('fixed_bottom');
		}
	});
});

$(document).ready(function(){
	//Hide (Collapse) the toggle containers on load
	$("#dictionary").hide(); 
	
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h2.chat_trigger").click(function() {
		$("#chat").slideToggle("slow");
		if ($("#chat").is(":visible") && $("#dictionary").is(":visible")){
			$("#dictionary").slideToggle("slow");
		}
		return false; //Prevent the browser jump to the link anchor
	});
	
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h2.dictionary_trigger").click(function(){
		$("#dictionary").slideToggle("slow");
		if ($("#dictionary").is(":visible") && $("#chat").is(":visible")){
			$("#chat").slideToggle("slow");
		}
		return false; //Prevent the browser jump to the link anchor
	});
});